<?php
 // while (list($name, $value) = each($HTTP_POST_VARS)) {

  //  echo "<br /><br />$name = $value<br />\n";

 // }
//echo session_encode();
$strScreenName = "scrCart";
$strFormName = "frmBasket";
$strQueryName = "actUpdateCart";
$intTotal = null; 
$strIntNumberOfItems = null;
if( (isset($_REQUEST['nRowID'])) && ($_REQUEST['nRowID'] != "") )
	$nRowID = $_REQUEST['nRowID'];
else 
	$nRowID = null;?>

<div id='VendereScreen'><?=
  	StartForm($strScreenName, "post", $strQueryName,array('nRowID'=>$nRowID),"","",$strFormName,"");?><?
	if($strStyleSheet == TRUE)
	{?>
		<table class='Normal' align='left' border='0' width='100%'><?
	}?>		 
		<tr class='ProductHeader'  bgcolor='silver' valign='middle'>
		      <td align='left' height='25' class='ProductHeader'>&nbsp;<img src='./vendere-images/shoppingcart.gif' width='20' height='20' border='0' alt=''/></td>
		      <td align='left' class='ProductHeader'>&nbsp;Shopping Cart</td>
		      <td align='center' class='ProductHeader'>&nbsp;</td>
		      <td align='center' class='ProductHeader'>&nbsp;</td>
		      <td align='right' class='ProductHeader'>Total&nbsp;</td>
		</tr><?
		
	// dumps info about a session 
	$session_array = explode(";",session_encode()); 

	for ($x = 0; $x < count($session_array); $x++) 
	{ 
		if (substr($session_array[$x],0,7)=="sesItem")
		{
			//if (eregi("(sesItem)([0-9]{1,9})(\|i\:)([0-9]{1,9})$",$session_array[$x], $OrderDetail)){
			//sesItem1_1_5|i:4
			if (eregi("(sesItem)([0-9]{1,9})(\_)([0-9]{1,9})(\_)([0-9]{1,9})(\|i\:)([0-9]{1,9})$",$session_array[$x], $OrderDetail)){	
				
				/*	
					$strhtml .= "0 - $OrderDetail[0] \n<br/>"; 
					$strhtml .= "1 - $OrderDetail[1] \n<br/>"; 
					$strhtml .= "2 -Product ID $OrderDetail[2] \n<br/>";
					$strhtml .= "3 - $OrderDetail[3] \n<br/>";  
					$strhtml .= "4 -Colour  $OrderDetail[4] \n<br/>";  
					$strhtml .= "5 - $OrderDetail[5] \n<br/>";  
					$strhtml .= "6 -Size  $OrderDetail[6] \n<br/>"; 
					$strhtml .= "7 - $OrderDetail[7] \n<br/>";  
					$strhtml .= "8 -Quantity  $OrderDetail[8] \n<br/>";
				//*/		
				$strSQL = "SELECT * FROM tblProduct
							WHERE tblProduct.ID =  '$OrderDetail[2]'";
				include (MODULE . "/action/actMySqlResults");
				//echo $strSQL."<br />";	
				//print_array($OrderDetail);
				$intSubTotal = $myrow["UnitPrice"] * $OrderDetail[8];
				$intTotal = $intTotal + $intSubTotal;
				$strIntNumberOfItems ++;  ?>

		          <tr class='Normal'>
		              <td align='center' class='Normal'><?
              
        				if((!$myrow["UploadedPicture"])||($myrow["UploadedPicture"]=="none")){
          					if(NO_PHOTO == "none")
          					{
          					}else{
          						echo "<img src='./vendere-css/images/".NO_PHOTO."' width='67' border='0' alt=\"".$myrow["Product"]." - click to enlarge\"/>";
          					}
        				}else{
        						echo "<img src='./images/product/thumbz/".$myrow["UploadedPicture"]."' width='72'  border='0' alt='".$myrow["Product"]."'/>";
        				}?>

					</td>
					<td align='left' valign='top' class='Normal'>
							<br />
    						<b><?=$myrow["Product"]?></b><?
              			
							if($myrow["QuantityPerUnit"]>1)
								echo "&nbsp;(".$myrow["QuantityPerUnit"]."&nbsp;pack)";
              			
							if($OrderDetail[4] > 0)
								echo "<br/> Colour: ".DisplayLookupValue("tblColour","Colour",$OrderDetail[4]);
							
							if($OrderDetail[6] > 0)
								echo "<br/> Size: ".DisplayLookupValue("tblSize","Size",$OrderDetail[6]);?>

    						<br />
    						<?=CURRENCY. number_format($myrow["UnitPrice"], 2, '.', '')?>
    						<br />Delete:
    						<img src='./vendere-images/trash.gif' width='20' height='20' border='0' alt=''/>
    						<input type='checkbox' name='chkDelete<?=$OrderDetail[2].$OrderDetail[3].$OrderDetail[4].$OrderDetail[5].$OrderDetail[6]?>' value='' onClick='frmBasket.submit()'>
					</td>
					<td align='right' valign='bottom' class='Normal'><b>Quantity:&nbsp;</b><?			
						CreateDropDownRange("cboQuantity".$OrderDetail[2].$OrderDetail[3].$OrderDetail[4].$OrderDetail[5].$OrderDetail[6],"1","225","$strFormName.submit()",$OrderDetail[8],"00");?>	
	              	</td>
	              	<td align='right'>&nbsp;</td>
	              	<td align='right' valign='bottom'>
	                	<?=CURRENCY.number_format($intSubTotal, 2, '.', '')?>
	              	</td>
	          </tr>
	
	          <tr>
	              <td colspan='5'><hr/></td>
	          </tr><?
			}
		}
	} 

	  if($strIntNumberOfItems > 0)
	  {?>
	      <tr class='Normal'>
	          <td align='left' class='normal'>Sub-Total</td>
	          <td align='center'>&nbsp;</td>
	          <td align='center'>&nbsp;</td>
	          <td align='center'>&nbsp;</td>
	          <td align='right'><?=CURRENCY.number_format($intTotal, 2, '.', '')?></td>
	      </tr>
	
	      <tr class='Normal'>
	          <td align='left'>Carriage</td>
	          <td align='center'>&nbsp;</td>
	          <td align='center'>&nbsp;</td>
	          <td align='center'>&nbsp;</td>
	          <td align='right'><?
	
	        	if (CARRIAGE != "0.00")
	        		  echo CURRENCY.number_format(CARRIAGE, 2, '.', '');
	        	else
	        		  echo "<span class='Small'>Included</span>";?>
	          </td>
	      </tr>
	      <tr class='Normal'>
	      		<td align='left'><b>Total</b></td>
	      		<td align='center'>&nbsp;</td>
	      		<td align='center'>&nbsp;</td>
	      		<td align='center'>&nbsp;</td>
	      		<td align='right'>
	      			<b><?=CURRENCY.number_format($intTotal + CARRIAGE, 2, '.', '')?></b>
	      		</td>
	    	</tr>
	
			<tr class='Small'>
				<td align='right' colspan='5'><hr /><?
					if(defined("CONTINUE_SHOPPING_BUTTON"))
					{?>
					  	<input type='button' value='Continue Shopping' onclick='history.go(-1); return false;'><?
					}?>
				  	<a href='<?=ScreenURL("scrCheckout")?>'>
				  		<img src='./images<?=SITE_SUFFIX?>/buychosenitems.gif' border='0' alt='buy chosen items'/>
				  	</a>
				</td>
	    	</tr>
	    	<tr class='Small'>
				<td align='center' colspan='5'>
			      	<hr /><?=BASKET_MESSAGE?>
			      	<br /><?=CHECKOUT_MESSAGE?>
				</td>
	    	</tr><?
	   }else{?>
	      <tr class='Small'>
	  		    <td align='right' colspan='5'>
	  		    	<hr />
	  		    	There is nothing in your Shopping Cart.
	  		    </td>
	  	  </tr>
	  	  <tr class='Small'>
	  		    <td align='center' colspan='5'>
			      	<hr /><?=BASKET_MESSAGE?>
			      	<br /><?=CHECKOUT_MESSAGE?>
				</td>
	  	  </tr><?
	   }   
		if($strStyleSheet == TRUE)
		{?>
		</table><?
		}echo "
	</form>";?>
</div>

